package com.sinping.qh.query.user;

import com.sinping.qh.query.base.Operator;
import com.sinping.qh.query.base.QueryParams;
import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 用户信息查询
 *
 * @author Tiansx
 * @create 2018-05-30 14:36
 **/
@Data
public class UserInfoQuery implements QueryParams, Serializable {
    private static final long serialVersionUID = 7313157797808045927L;
    static Map<String, String> aliasMap = new HashMap<>();
    static Map<String, Operator> operatorMap = new HashMap<>();

    /**
     * 用户名
     */
    private String userName;
    /**
     * 姓名
     */
    private String fullName;

    /**
     * 所属单位id
     */
    private String unitId;

    private String status;
    /**
     * 登录人负责单位集合
     */
    private List<String>unitIdList;



    static {
        aliasMap.put("userName", "user_name");
        aliasMap.put("fullName", "full_name");
        aliasMap.put("unitId", "unit_id");
        aliasMap.put("status","status");
        aliasMap.put("unitIdList","unit_id");
        operatorMap.put("userName", Operator.regex);
        operatorMap.put("fullName",Operator.regex);
        operatorMap.put("unitId", Operator.eq);
        operatorMap.put("status", Operator.eq);
        operatorMap.put("unitIdList",Operator.in);
    }

    @Override
    public String getAlias(String fieldName) {
        return aliasMap.getOrDefault(fieldName, fieldName);
    }

    @Override
    public Operator getOperators(String fieldName) {
        return operatorMap.getOrDefault(fieldName, Operator.eq);
    }


}
